home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: SplitKick.c 1.003 (13.01.97) © Gian Maria Calzolari
- **
- **
- ** FUNCTION:
- ** Dato un kickfile lo splitta per essere scritto su due eprom:
- **
- ** AmigaOS accede al kick a 32bit e quindi usa due chip in cui preleva
- ** una WORD (16bit) da ognuna per "comporre" i 32bit!
- **
- ** $HISTORY:
- **
- ** 13 Jan 1997 : 001.003 : Lettura diretta del file anzichè da un buffer di
- ** memoria, aggiunta gestione argomenti
- ** 06 Jan 1997 : 001.002 : Aggiunti controlli vari
- ** 05 Jan 1997 : 001.001 : Da esempio di Wiz
- **
- */
-
- #include "SplitKick.h"
-
- // Questo serve *solo* per avere EOF definito...
- #include <stdio.h>
-
- void main( void ) {
- LONG i, ic;
- TEXT Out1[256], Out2[256];
-
- args[ARG_INPUT ] = (APTR) NULL;
- args[ARG_OUTPUT] = "Ram:KickImg";
-
- if ( (rda = ReadArgs(Template, (LONG *)args, NULL) ) == NULL)
- erroreAD(NULL);
-
- sprintf(Out1,"%s%d", args[ARG_OUTPUT], 1);
- sprintf(Out2,"%s%d", args[ARG_OUTPUT], 2);
-
- from = Open(args[ARG_INPUT], MODE_OLDFILE);
-
- if (from == 0)
- erroreAD("Apertura KickFile input");
-
- to1 = Open(Out1, MODE_NEWFILE );
-
- if (to1 == 0)
- erroreAD("Apertura 'lo' image");
-
- to2 = Open(Out2, MODE_NEWFILE );
-
- if (to2 == 0)
- erroreAD("Apertura 'hi' image");
-
- PutStr ( version );
- PutStr ( "\n" );
-
- // 131072 è il numero di words (16bits) in 256K
- for( i = 0; i < 131072; i++ ) {
-
- // 16 bits in uno...
- if ( (ic = FGetC(from) ) == EOF)
- erroreAD("Fine prematura file input!");
-
- if ( FPutC(to1, ic) == EOF)
- erroreAD("Errore inatteso scrittura primi 8 bits 'lo'");
-
- if ( (ic = FGetC(from) ) == EOF)
- erroreAD("Fine prematura file input!");
-
- if ( FPutC(to1, ic) == EOF)
- erroreAD("Errore inatteso scrittura secondi 8 bits 'lo'");
-
- // ...e 16 bits nell'altro!
- if ( (ic = FGetC(from) ) == EOF)
- erroreAD("Fine prematura file input!");
-
- if ( FPutC(to2, ic) == EOF)
- erroreAD("Errore inatteso scrittura primi 8 bits 'hi'");
-
- if ( (ic = FGetC(from) ) == EOF)
- erroreAD("Fine prematura file input!");
-
- if ( FPutC(to2, ic) == EOF)
- erroreAD("Errore inatteso scrittura secondi 8 bits 'hi'");
- }
-
- fine();
- exit(RETURN_OK);
- }
-
- /// Routines generiche
- /* ----------------------------------- fine ------------------------------------
-
- Comment:
-
- Chiusura programma
-
- */
-
- void fine(void) {
-
- if (rda) {
- FreeArgs(rda);
- rda = NULL;
- }
-
- if (from) {
- Close( from );
- from = 0;
- }
-
- if ( to1 ) {
- Close( to1 );
- to1 = 0;
- }
-
- if ( to2 ) {
- Close( to2 );
- to2 = 0;
- }
-
- }
-
- /* --------------------------------- ErroreAD ----------------------------------
-
- Comment:
-
- Visualizza un messaggio per errori generati da AmigaDOS
-
- str -> puntatore ad una stringa di testo
-
- */
-
- void erroreAD(STRPTR str)
- {
- TEXT c[256] = "";
-
- if ( IoErr() )
- Fault(IoErr(), str, c, sizeof(c) );
- else
- PutStr( str );
-
- PutStr( c );
- PutStr( "\n" );
-
- fine();
- exit(RETURN_FAIL);
- }
- ///
-
-